home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE19 / EX2.C < prev    next >
C/C++ Source or Header  |  1995-05-13  |  1KB  |  40 lines

  1. // ex2.c
  2.  
  3. #include <windows.h>
  4. #include <genstub.c>
  5. #include <winreg.h>
  6.  
  7. LRESULT FAR PASCAL WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  8. {
  9.     switch( uMsg )
  10.     {
  11.         case WM_COMMAND:    // process menu items
  12.             switch( wParam )
  13.             {
  14.                 case IDM_TEST:
  15.                 {
  16.                     HKEY  hKeyResult = 0;
  17.                     LONG  lResult = RegOpenKeyEx( HKEY_CLASSES_ROOT,
  18.                                                    "MyDoc\\shell\\&Test\\command",
  19.                                                    0, KEY_ALL_ACCESS, &hKeyResult );
  20.  
  21.                     if ( lResult == ERROR_SUCCESS ) // delete default value
  22.                          lResult = RegDeleteValue( hKeyResult, NULL );
  23.                     RegCloseKey( hKeyResult );
  24.                     RegDeleteKey( HKEY_CLASSES_ROOT, "MyDoc" );
  25.                     RegDeleteKey( HKEY_CLASSES_ROOT, ".MDC" );
  26.                 }
  27.                 break;
  28.                 case IDM_EXIT:
  29.                     DestroyWindow( hWnd );
  30.                     break;
  31.             }
  32.             break;
  33.         case WM_DESTROY:
  34.             PostQuitMessage( 0 );
  35.             break;
  36.         default:            // default windows message processing
  37.             return DefWindowProc( hWnd, uMsg, wParam, lParam );
  38.     }
  39.     return( 0L );
  40. }